import { login, showModal, showToast } from "../../utils/asyncWx.js";
import { request } from '../../request/index.js';
import regeneratorRuntime from '../../lib/runtime/runtime';


Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

  },
  async handleGetUserInfo(e) {
    try {
      let { encryptedData, rawData, iv, signature } = e.detail
      let { code } = await login()
      let params = { encryptedData, rawData, iv, signature, code }
      // let result = await request({
      //   url:'/users/wxlogin',
      //   data: params,
      //   method: 'post'
      // })
      let token = "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOjIzLCJpYXQiOjE1NjQ3MzAwNzksImV4cCI6MTAwMTU2NDczMDA3OH0.YPt-XeLnjV-_1ITaXGY2FhxmCe4NvXuRnRB8OMCfnPo"
      wx.setStorageSync("token", token);
      wx.navigateBack({
        delta: 1
      });
    } catch(err) {
      console.log(err);
    }
      
      
  }
})